package main

import (
	"fmt"
	"studyDemo/splits"
)

type Person struct {
	Name  string  `json:"name"`
	Age   int     `json:"age"`
	Wight float64 `json:"wight"`
}

func main() {
	//base.FlowController(11, 5)
	//arr := []int{7, 3, 9, 10, 8}
	//min := base.GetMin(arr)
	//fmt.Printf("最小值为：%d\n", min)
	//// 返回多个值
	//x, y := base.ReturnMany(2, 6)
	//println(x, y)
	//base.ManyParams(1, 8, 5, 45)
	//// 引用传递
	//
	//base.PointerDelivery(&x, &y)
	//println(x, y)
	//base.NonameMethod()

	// 面向对象
	//equal := myObject.Triangle{Bottom: 2.5, Height: 6}
	//// 获取面积
	//area := equal.Area()
	//fmt.Println(area)
	//
	//// 实例化对象
	//student := new(myObject.Student)
	//student.SetName("李四")
	//student.Age = 18
	//
	//fmt.Println(student)
	//
	//t := &myObject.Triangle{Bottom: 6, Height: 8}
	//s := &myObject.Square{SideLen: 5}
	//
	//shapes := []myObject.Shape{t, s}
	//for _, value := range shapes {
	//	fmt.Println("图形的数据是：", value)
	//	fmt.Println("图形的面积是：", value.Area())
	//}

	// 字符串切片
	//str := []byte("This is slice")
	//slice := []int{1, 2, 3}
	//
	//fmt.Printf("str: %v, slice: %v", string(str), slice)

	// 接口查询
	//slice := make([]int, 0)
	//slice = append(slice, 2, 3, 4)
	//
	//var i interface{} = slice
	//if res, ok := i.([]int); ok {
	//	fmt.Println(res)
	//	fmt.Println(ok)
	//}
	////fmt.Println(slice)
	//// 类型推断
	//var a interface{} = func(a int) string {
	//	return fmt.Sprintf("d:%d", a)
	//}
	//
	//fmt.Println()
	//
	//switch b := a.(type) {
	//case nil:
	//	fmt.Println("nil")
	//case *int:
	//	fmt.Println(*b)
	//case func(int) string:
	//	println(b(66))
	//case fmt.Stringer:
	//	fmt.Println(b)
	//default:
	//	println("unknown")
	//}
	//
	//// 多态
	//user := base.User{Name: "张三", Phone: "1232323"}
	//admin := base.Admin{Name: "李四", Phone: "93232"}
	//
	//base.SendMessage(&user)
	//base.SendMessage(&admin)
	//
	//var value float32 = 34.123
	//
	//fmt.Println("反射数据类型:", reflect.TypeOf(value))
	//fmt.Println("反射数据的值:", reflect.ValueOf(value))
	//
	//var name string = "golang is the best language!"
	//fmt.Println("原始值：", name)
	//// 反射值
	//v := reflect.ValueOf(&name).Elem()
	//
	//v.SetString("php is the best language!")
	//
	//fmt.Println("新的值：", name)

	//go HelloWord()
	//// 睡一秒
	//time.Sleep(1 * time.Second)
	//fmt.Println("end")

	//p := Person{
	//	Name:  "zhngsan",
	//	Age:   18,
	//	Wight: 60.8,
	//}
	// 结构体转化为json
	//b, _ := json.Marshal(p)
	//
	//fmt.Println(string(b))
	//var p2 Person
	//_ = json.Unmarshal(b, &p2)
	//
	//fmt.Printf("%v", p2)
	//
	//const (
	//	a = iota + 100
	//	c
	//	d
	//
	//	fg
	//	g
	//)
	//
	//fmt.Println(a, c, d, fg, g)

	fmt.Println(splits.Split("abc", "b"))
}

func HelloWord() {
	fmt.Println("this is a goroutine msg")
}
